package com.tommy.ddp.manager
{
	import com.tommy.ddp.definition.DDPConfig;
	import com.tommy.ddp.pipeline.Pipeline;
	
	import flash.geom.Point;
	
	import org.taomee.ds.HashMap;

	public class PipelineDataManager
	{
		private static var _pipelineHashMap:HashMap;
		
		public function PipelineDataManager()
		{
		}
		/**
		 * 创建管道序列（重新刷新计算一遍地图上的管道信息）
		 * 
		 */		
		public static function createPipelineList():void
		{
			if(_pipelineHashMap)
			{
				_pipelineHashMap.clear();
			}
			_pipelineHashMap = new HashMap();
			for(var i:uint = 0;i<DDPConfig.W_NUM;i++)
			{
				var pipeline:Pipeline = new Pipeline();
				_pipelineHashMap.add(i,pipeline);
			}
			
			for(i = 0;i<DDPConfig.W_NUM;i++)
			{
				pipeline = _pipelineHashMap.getValue(i);
				pipeline.setup(i);
			}
		}
		
		public static function dispose():void
		{
			if(_pipelineHashMap)
			{
				var arr:Array = _pipelineHashMap.getValues();
				for each(var i:Pipeline in arr)
				{
					i.dispose();
				}
				_pipelineHashMap.clear();
			}
		}
		/**
		 * 获取管道最大长度
		 * @return 
		 * 
		 */		
		public static function get maxLength():uint
		{
			return DDPConfig.H_NUM;
		}
		
		public static function getPipeline(index:uint):Pipeline
		{
			return _pipelineHashMap.getValue(index);
		}
		
		public static function get allPipelines():Array
		{
			return _pipelineHashMap.getValues();
		}
	}
}